home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
033a
/
mxtms_10.zip
/
FILE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-27
|
3KB
|
123 lines
/****************************************************************************/
/* */
/* File.c Version 1.0 By Craig Derouen */
/* A Maximus CBBCS Timebank program */
/* */
/* */
/****************************************************************************/
#include "maxtime.h"
#include "globals.h"
struct user_cfg uscfg;
/* Find the user in the config file */
int find_config(int handle,char *name,struct user_cfg *uscfg)
{
int x,y;
x = 0;
lseek(handle,0L,SEEK_SET); /* Rewind to begginning */
while (1) {
y = read(handle,(char *) uscfg,sizeof(struct user_cfg));
if( y < sizeof(struct user_cfg))
return(-1);
if (strcmpi(uscfg->name,name) == 0) { /* It's found! */
return(x);
}
x++; /* Try next user */
}
}
/* Find a blank slot in the config file */
int find_blconfig(int handle)
{
int x,y;
struct user_cfg uscfg;
x = 0;
lseek(handle,0L,SEEK_SET); /* Rewind to begginning */
while (1) {
y = read(handle,(char *) &uscfg,sizeof(struct user_cfg));
if( y < sizeof(struct user_cfg))
return(-1);
if (uscfg.isused == 0) /* It's found! */
return(x);
x++; /* Try next user */
}
}
void newuser_help(void)
{
setcolor(TextAttr[STD_TEXT]);
if(show_file(NewHelpFil) >= 0) {
setcolor(TextAttr[HILITE_TEXT]);
strout("\r\n\r\nPress any key to exit.");
chrinwait(1);
strout("\r\n");
}
}
int show_file(char *strng)
{
FILE *newfile;
int linecount;
char ltemp[81];
if (strng[0] == '\0')
return(-1); /* No help file */
newfile = _fsopen(strng,"r",SH_DENYNO); /* Open in read only, text mode */
if (newfile == NULL) {
sprintf(ltemp,"Error opening %s file for user.",strng);
logit(ltemp,'!');
return(-1); /* Just skip it */
}
linecount = 0;
while (!feof(newfile)) {
if(fgets(ltemp,80,newfile)) {
if (linecount > 22) { /* Turn on more for paging */
strout("\r\n\r\nPress any key for more");
chrinwait(1);
strout("\r\n");
linecount = 0;
}
strout(ltemp);
strout("\r");
linecount++;
}
}
fclose(newfile);
return(0);
}
int new_user(int filenum)
{
int x,y;
struct user_cfg uscfg;
x = 0;
/* Seek to start of file and count records */
if(lseek(filenum,0L,SEEK_SET) >= 0L) { /* Rewind to begginning */
y = read(filenum,(char *) &uscfg,sizeof(struct user_cfg));
while (y == sizeof(struct user_cfg)) {
x++; /* Simple count */
y = read(filenum,(char *) &uscfg,sizeof(struct user_cfg));
}
}
return(x);
}
void update_usercfg(int filenum)
{
lseek(filenum,(long) (UserCfgnum * sizeof(struct user_cfg)),SEEK_SET); /* Append to tail of file */
write(filenum,(struct user_cfg *) &USERCFG,sizeof(struct user_cfg));
}